package day14_21.day14;

import java.util.Scanner;

public class Main01 {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int year = scn.nextInt();
        int month = scn.nextInt();
        int day = scn.nextInt();
        int num = 0;
        int[] array = {31 , 0 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
        if (isYear(year)){
            array[1] = 29;
        }else {
            array[1] = 28;
        }
        for (int i = 0; i < month - 1; i++) {
            num += array[i];
        }
        num += day;
        System.out.println(num);
     }

    private static boolean isYear(int year) {
        return  year % 4 == 0;
    }
}
